package com.tao.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @ClassName ConsumerController
 * @Author HETAO
 * @Date 2020/5/12 15:23
 */
@RestController
@RequestMapping("nacos")
public class ConsumerController {
    @Value("${server-url.nacos-use-service}")
    private String SERVER_URL;

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("client/{id}")
    public String getData(@PathVariable("id") Long id) {
        return this.restTemplate.getForObject(SERVER_URL+"/nacos/get",String.class);
    }
}
